﻿using Entity;
using IRealize;
using Microsoft.AspNetCore.Mvc;
using Realize;

namespace WebApplication9.Controllers.Recruit_Manage.MS
{
    public class ERAndEI_AUSController : Controller
    {
        private readonly IConfiguration configuration;

        public ERAndEI_AUSController(IConfiguration configuration)
        {
            this.configuration = configuration;
        }
        public IActionResult Index()
        {
            return View();
        }

        public async Task<IActionResult> Select_ER(int CurrentPage, int PageSize)
        {
            IER emr = new ER();
            List<Engage_Resume> zhi = await emr.Select(configuration["SqlServer"]);
            List<Engage_Resume> zhi2 = zhi.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();
            PagedViewModel<Engage_Resume> cc = new PagedViewModel<Engage_Resume>() { itemas = zhi2, total = zhi.Count };
            return Ok(new
            {
                list = cc
            });
        }

        public IActionResult EIAdd(string id)
        {
            ViewBag.TitleId = id;
            return View();
        }

        [HttpGet]
        public async Task<IActionResult> SelectById_ER(string id)
        {
            IER ier = new ER();
            Engage_Resume er = await ier.SelectById(id, configuration["SqlServer"]);
            return Ok(new
            {
                zhi = er
            });
        }

        [HttpGet]
        public async Task<IActionResult> Add(string HumanName, int InterviewAmount, string HumanMajorKindId, string HumanMajorKindName, string HumanMajorId, string HunmaMajorName, string ImageDegree, string NativeLanguageDegree, string ForeignLanguageDegree, string ResponseSpeedDegree, string EQDegree, string IQDegree, string MultiQualityDegree, string Register, string RegisteTime, string ResumeId, string InterviewComment)
        {
            IEI eI = new EI();
            int result = await eI.Add(HumanName, InterviewAmount, HumanMajorKindId, HumanMajorKindName, HumanMajorId, HunmaMajorName, ImageDegree, NativeLanguageDegree, ForeignLanguageDegree, ResponseSpeedDegree, EQDegree, IQDegree, MultiQualityDegree, Register, RegisteTime, ResumeId, InterviewComment, configuration["SqlServer"]);
            if (result > 0)
            {
                return Ok(new
                {
                    zhi="ok"
                });
            }
            else
            {
                return Ok(new
                {
                    zhi="nook"
                });
            }
        }
    }
}
